package com.zbkj.admin.controller.brand;

import com.zbkj.common.page.CommonPage;
import com.zbkj.common.request.PageParamRequest;
import com.zbkj.common.request.TraceableGroupBrandSearchRequest;
import com.zbkj.common.request.TraceableGroupSaveRequest;
import com.zbkj.common.response.TraceableGroupBrandPageDataResponse;
import com.zbkj.common.result.CommonResult;
import com.zbkj.service.service.TraceableGroupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 品牌商溯源套餐管理 前端控制器
 */
@Slf4j
@RestController
@RequestMapping("api/admin/brand/traceable/group")
@Api(tags = "品牌商溯源套餐管理") //配合swagger使用

public class BrandTraceableGroupController {

    @Autowired
    private TraceableGroupService traceableGroupService;

    /**
     * 分页显示溯源套餐表
     *
     * @param request          搜索条件
     * @param pageParamRequest 分页参数
     * @author dazongzi
     * @since 2025-07-08
     */
    //@PreAuthorize("hasAuthority('platform:activitystyle:list')")
    @ApiOperation(value = "分页列表") //配合swagger使用
    @RequestMapping(value = "/page/list", method = RequestMethod.GET)
    public CommonResult<CommonPage<TraceableGroupBrandPageDataResponse>> getList(@Validated TraceableGroupBrandSearchRequest request,
                                                                   @ModelAttribute PageParamRequest pageParamRequest) {
        CommonPage<TraceableGroupBrandPageDataResponse> traceableGroupCommonPage =
                CommonPage.restPage(traceableGroupService.getListBrand(request, pageParamRequest));
        return CommonResult.success(traceableGroupCommonPage);
    }


    /**
     * 修改溯源套餐表
     * @param traceableGroupRequest 修改参数
     * @author dazongzi
     * @since 2025-07-08
     */
    @ApiOperation(value = "修改")
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public CommonResult<String> update(@RequestBody @Validated TraceableGroupSaveRequest traceableGroupRequest) {
        if (traceableGroupService.updateBrand(traceableGroupRequest)) {
            return CommonResult.success();
        } else {
            return CommonResult.failed();
        }
    }

}



